﻿using IntelligentPharmacy;
using IntelligentPharmacy.Entity;
using IntelligentPharmacy.httprequest;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;

namespace SmartRoom
{
    /// <summary>
    /// OutWindowsDetail.xaml 的交互逻辑
    /// </summary>
    public partial class OutDetailWindow : Window
    {
        requestService request = new requestService();
        List<TagEntity> lists = new List<TagEntity>();
        public OutDetailWindow()
        {
            InitializeComponent();
        }


        private System.Windows.Forms.Timer _tagTimer = new System.Windows.Forms.Timer();

        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            List<TagEntity> tagEntities =  request.getStockList();

            lbl_LYTotl.Content = lists.Count;
        }


        private void btn_Exit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }


        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnC_Submit_Click(object sender, RoutedEventArgs e)
        {
          
        }
        private void btn_Clear_Click(object sender, RoutedEventArgs e)
        {
           
        }
        private void Window_Closing_1(object sender, System.ComponentModel.CancelEventArgs e)
        {
           
        }
        private void Complete_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            
        }
        private void btn_Delete_Click(object sender, RoutedEventArgs e)
        {
           
        }
        /// <summary>
        /// 库存查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txt_Search_Click(object sender, RoutedEventArgs e)
        {

            try
            {
                List<MaterialnformationEntity> listinfo = request.getRfidContent(lists);
                List<TagEntity> tagEntities = request.getStockList();
                List<MaterialnformationEntity> entities = request.getRfidContent(tagEntities);
                lbl_LYTotl.Content = tagEntities.Count;
                lvw_RK.ItemsSource = entities;
            }catch(Exception ex) { }

            /*
            List<MaterialnformationEntity>  lists=listinfo.FindAll(delegate(MaterialnformationEntity infos) {
                 if (string.IsNullOrEmpty(txt_CPMC.Text))
                 {
                     return true;
                 }
                 else
                 {
                     if (infos.goodsName.Equals(txt_CPMC.Text))//根据名称
                         return true;
                 }
                 return false ;
            })
            .FindAll(delegate (MaterialnformationEntity infos)
            {
                if (string.IsNullOrEmpty(txt_CPGG.Text))
                {
                    return true;
                }
                else
                {
                    if (infos.goodsType.Equals(txt_CPGG.Text))//根据规格
                        return true;
                }
                return false;
            })
             .FindAll(delegate (MaterialnformationEntity infos)
             {
                 if (string.IsNullOrEmpty(txt_CPPH.Text))
                 {
                     return true;
                 }
                 else
                 {
                     if (infos.lotName.Equals(txt_CPPH.Text))
                         return true;
                 }
                 return false;
             });*/
        }

        private void txt_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.Enter)
            {
                txt_Search_Click(null, null);
            }
        }

        private void Complete_Checked(object sender, RoutedEventArgs e)
        {
           
        }

        private void lvw_RK_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
          
        }

        private void lvw_RK_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
        }

        private void lvw_RK_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
          
        }

        private void lvw_RK_TouchDown(object sender, System.Windows.Input.TouchEventArgs e)
        {
           
        }
    }
}
